{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2409ab7a",
   "metadata": {},
   "source": [
    "## 练习\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05e45987",
   "metadata": {},
   "outputs": [],
   "source": [
    "vowles = ['a','e','i','o','u']     # 这是元音list\n",
    "word = \"Milliways\"  # 这是文本\n",
    "# 需求：word中出现的 vowels 打印出来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac3312e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 循环遍历的第一个位置的元素请注意名字不要和已经定义过的变量重复\n",
    "\n",
    "# for循环的第二个元素，决定了我们循环的内容。循环的列表，每个元素单独在一行打印"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a7368794",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "vowles = ['a','e','i','o','u']\n",
    "word = \"Milliways\"\n",
    "\n",
    "for letter in word:  # letter 可以随便命名，不会影响我们的结果\n",
    "                     #  一般情况下，item（内容）→简写 i\n",
    "#    print(letter)\n",
    "    if letter in vowles:\n",
    "        print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "345532b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['i', 'a']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# append ()经常用于新建列表\n",
    "found = []\n",
    "for letter in word:\n",
    "    if letter in vowles:\n",
    "        if letter not in found:\n",
    "            found.append(letter)\n",
    "found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d0bf99cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "goods_list = [[\"phone\",4000],[\"computer\",8000],[\"mouse\",50],[\"keyboard\",200]]\n",
    "\n",
    "user_shopping_list =[\"\"]\n",
    "\n",
    "Alipay = input(\"请输入您的余额：\")\n",
    " print('''------- goods detail -------''')\n",
    "for i in range(4):\n",
    "     print(\"编号%s，商品名称：%s,商品价格: %s 元%\"(i,goods_list[i][0],goods_list[i][1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "975a5f0f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的余额：\n",
      "------- goods detail -------\n",
      "编号0，商品名称：phone,商品价格: 4000 元\n",
      "编号1，商品名称：computer,商品价格: 8000 元\n",
      "编号2，商品名称：mouse,商品价格: 50 元\n",
      "编号3，商品名称：keyboard,商品价格: 200 元\n",
      "\n"
     ]
    }
   ],
   "source": [
    "goods_list = [[\"phone\",4000],[\"computer\",8000],[\"mouse\",50],[\"keyboard\",200]]\n",
    "#### 嵌套\n",
    "# 2、用户购物信息\n",
    "user_shopping_list =[\"\"]\n",
    "# 用户输入（余额）：\n",
    "Alipay = input(\"请输入您的余额：\")\n",
    "info = '''------- goods detail -------\n",
    "编号0，商品名称：%s,商品价格: %s 元\n",
    "编号1，商品名称：%s,商品价格: %s 元\n",
    "编号2，商品名称：%s,商品价格: %s 元\n",
    "编号3，商品名称：%s,商品价格: %s 元\n",
    "'''%(goods_list[0][0],goods_list[0][1],\n",
    "     goods_list[1][0],goods_list[1][1],\n",
    "     goods_list[2][0],goods_list[2][1],\n",
    "     goods_list[3][0],goods_list[3][1])\n",
    "print(info)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f27d72f6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
